package com.boot.seven.rabbitmq.simple;


import com.boot.seven.constant.MqConstant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

@Slf4j
@Component
public class SimpleMsgProducer {

    @Autowired
    private AmqpTemplate rabbitTemplate;

    public void send() {
        String msgContent = "Hello World";
        log.info("[生产者] 发送消息: {}", msgContent);
        this.rabbitTemplate.convertAndSend(MqConstant.SIMPLE_QUEUE, msgContent);
    }

    public void send2() {
        Map<String,Object> map=new HashMap<>();
        map.put("name","张三");
        map.put("age","12");
        log.info("[生产者] 发送消息: {}", map);
        this.rabbitTemplate.convertAndSend(MqConstant.SIMPLE_QUEUE_2, map);
    }

}
